package weaver.interfaces.jjy.duss.hr;

import com.sap.mw.jco.JCO;
import weaver.interfaces.jjy.duss.util.SAPConnPool;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @program: ecology-9-demo
 * @description: 月度绩效B
 * @author: Dusongsong
 * @create: 2019-12-07
 */

public class ZFM_HR_031B {
    public Map execute(List<Map<String, String>> mapList) {

        //Map<String, String> map = new HashMap<String, String>();
        SAPConnPool SAPConn = new SAPConnPool();
        JCO.Client myConnection = SAPConn.getConnection();
        JCO.Function bapi = SAPConn.excuteBapi("ZFM_HR_031B");
        JCO.ParameterList input = bapi.getImportParameterList();//输入参数和结构处理
        JCO.ParameterList inputtable = bapi.getTableParameterList();//输入表的处理

        //入参为表
        JCO.Table t1 = inputtable.getTable("IT_TABLE");
        for (Map<String, String> map :mapList) {
            t1.appendRow();
            t1.setValue(map.get("GJAHR"), "GJAHR");         //年度
            t1.setValue(map.get("MONAT"), "MONAT");         //月度
            t1.setValue(map.get("PERNR"), "PERNR");         //人员编码
            t1.setValue(map.get("JBXYGZ"), "JBXYGZ");       //加班效益工资
            t1.setValue(map.get("JBTCGZ"), "JBTCGZ");       //加班提成工资
            t1.setValue(map.get("BMGDSK"), "BMGDSK");       //部门规定收款提成
            t1.setValue(map.get("SKTC"), "SKTC");           //收款提成
            t1.setValue(map.get("ZZSKJTC"), "ZZSKJTC");     //自助收款机提成
            t1.setValue(map.get("JLJJ"), "JLJJ");           //激励奖金
        }
        //执行函数
        myConnection.execute(bapi);
        JCO.ParameterList out = bapi.getExportParameterList();//输出参数和结构处理
        JCO.ParameterList Table00 = bapi.getTableParameterList();//输出表的处理

        //返回处理结果以及日志
        JCO.Table stu = Table00.getTable("IT_TABLE");
        Map<String, String> mapreturn = new HashMap<>();
        String flag = (String) stu.getValue("ZFLAG");
        String message = (String) stu.getValue("ZMESG");
        mapreturn.put("flag", flag);
        mapreturn.put("message", message);
        JCO.releaseClient(myConnection);
        return mapreturn;
    }
}
